<template>
  <div class="m_left" ref="navContainer">
    <div class="left_n">管理中心</div>
    <div class="left_m" v-if="userType === 1">
      <div class="left_m_t t_bg1">订单管理</div>
      <ul>
        <li><router-link to="/user/orders-management">订单管理</router-link></li>
      </ul>
    </div>
    <div class="left_m" v-if="userType === 1">
      <div class="left_m_t t_bg3">资讯管理</div>
      <ul>
        <li><router-link to="/user/news">资讯管理</router-link></li>
      </ul>
    </div>
    <div class="left_m" v-if="userType === 1">
      <div class="left_m_t t_bg2">系统管理</div>
      <ul>
        <li><router-link to="/user/management">用户管理</router-link></li>
        <li><router-link to="/user/product">商品管理</router-link></li>
      </ul>
    </div>
    <div class="left_m">
      <div class="left_m_t t_bg4">账户中心</div>
      <ul>
        <li><router-link to="/user/security">账户安全</router-link></li>
        <li><router-link to="/user/address">地址管理</router-link></li>
        <li><router-link to="/user/favorites">我的收藏</router-link></li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name: 'UserCenterNav',
  props: {
    userType: {
      type: Number,
      default: 0
    }
  },
  beforeUnmount() {
    // 确保在组件卸载前清理可能的引用
    if (this.$refs.navContainer) {
      // 清理可能存在的事件监听器
      if (this.$refs.navContainer.removeEventListener) {
        // 移除所有可能的事件监听器
        const container = this.$refs.navContainer
        const clone = container.cloneNode(true)
        if (container.parentNode) {
          container.parentNode.replaceChild(clone, container)
        }
      }
    }
    
    // 清理可能的定时器
    if (this.navTimer) {
      clearTimeout(this.navTimer)
      this.navTimer = null
    }
    
    // 清理组件引用
    if (this.$refs.navContainer) {
      this.$refs.navContainer = null
    }
    if (this.$el) {
      this.$el = null
    }
  }
}
</script>

<style scoped>
</style>